*** State-level models: Militarization
** Table 1

	
xtset statecode year

set more off
set matsize 11000
******************************************* MAIN PAPER  *******************************************
****** Table 2
**** OLS
*** FE
** DV: Count of journalists killed
* No controls
eststo clear
set more off
eststo: xtreg count jointopsyeardummy i.year, cluster(statecode) fe
	estadd local statefe  "Y" 
	estadd local yearfe  "Y"
	estadd local timetrend  "N"

* With controls
eststo: xtreg count jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ i.year, cluster(statecode) fe
	estadd local yearfe  "N"
	estadd local timetrend  "Y"

eststo: xtreg count jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ year, cluster(statecode) fe
	estadd local yearfe  "N"
	estadd local timetrend  "Y"


** DV: dummy for journalists killed
* No controls
eststo: xtreg count_dummy jointopsyeardummy i.year, cluster(statecode) fe
	estadd local statefe  "Y" 
	estadd local yearfe  "Y"
	estadd local timetrend  "N"

* With controls
eststo: xtreg count_dummy jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ i.year, cluster(statecode) fe
	estadd local statefe  "Y" 
	estadd local yearfe  "Y"
	estadd local timetrend  "N"

eststo: xtreg count_dummy jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ year, cluster(statecode) fe
	estadd local statefe  "Y" 
	estadd local yearfe  "N"
	estadd local timetrend  "Y"


esttab using "Table2.rtf", cell(b(star fmt (%9.2f)) se(par)) ///
       uns drop(_cons *.year year) compress fonttbl(\f0\fnil Garamond; ) ///
       stats(N statefe yearfe timetrend, fmt(%9.0g) labels("N" "State FE" "Year FE" "Time trend")) starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
	   o(jointopsyeardummy) ///
	   note("Note: Standard errors clustered at the state level in parenthesis. FE = Fixed Effects. + p<0.1; * p<0.05; ** p<0.01; *** p<0.001") ///
	   varlabels(jointopsyeardummy "Military intervention" lag1_hom "Homicide rate (t–1)" loggdppercap "GDP per capita (logged)" deudapib100 "Debt/GDP" taxgdp100 "Taxation/GDP" taxgdp100 "Taxation/GDP"  divided "Divided government" educ "Education (years)") ///
	   title("Table 1. The Impact of Militarization on Attacks vs. Journalists by Mexican State, 1994–2015") replace


******************************************* APPENDIX *******************************************
**** Table A.IV.a
eststo clear
* FE
eststo: xtreg count jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ, cluster(statecode) fe
   
* RE
eststo: xtreg count jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ, cluster(statecode)

** NB
* FE
eststo: xtnbreg count jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ i.year, i(statecode) fe

* RE
eststo: xtnbreg count jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ, i(statecode) re
		
esttab using "Table A.IV.a.rtf", cell(b(star fmt (%9.2f)) se(par)) ///
       uns drop(_cons *.year) compress fonttbl(\f0\fnil Garamond; ) ///
       stats(N, fmt(%9.0g) labels("N" "State FE" "Year FE" "Time trend")) starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
	   note("Note: Standard errors clustered at the state level in parenthesis. FE = Fixed Effects. + p<0.1; * p<0.05; ** p<0.01; *** p<0.001") ///
	   varlabels(jointopsyeardummy "Military intervention" lag1_hom "Homicide rate (t–1)" loggdppercap "GDP per capita (logged)" deudapib100 "Debt/GDP" taxgdp100 "Taxation/GDP" taxgdp100 "Taxation/GDP"  divided "Divided government" educ "Education (years)") ///
	   title("Table A.IV.a. The Impact of Militarization on Attacks vs. Journalists by Mexican State, 1994–2015") replace
		  
**** Table A.IV.b
eststo clear
** No controls
eststo: reghdfe count sedena_of_t5_atuesta, cluster(statecode) a(year statecode) // official info
estadd local statefe  "Y" 
estadd local yearfe  "Y" 

eststo: reghdfe count sedena_cide_t5_atuesta, cluster(statecode) a(year statecode) // CIDE-PPD
estadd local statefe  "Y" 
estadd local yearfe  "Y" 

** With controls
eststo: reghdfe count sedena_of_t5_atuesta lag1_hom loggdppercap deudapib100 taxgdp100 divided educ, cluster(statecode) a(year statecode) // official info
estadd local statefe  "Y" 
estadd local yearfe  "Y" 

eststo: reghdfe count sedena_cide_t5_atuesta lag1_hom loggdppercap deudapib100 taxgdp100 divided educ, cluster(statecode) a(year statecode) // CIDE-PPD
estadd local statefe  "Y" 
estadd local yearfe  "Y" 

esttab using "Table A.IV.b.rtf", cell(b(star fmt (%9.2f)) se(par)) ///
       uns drop(_cons) keep() compress mtitles() fonttbl(\f0\fnil Garamond; )  ///
       stats(N statefe yearfe, fmt(%9.0g) labels("N" "State FE" "Year FE")) ///
	   starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
	   varlabels(sedena_of_t5_atuesta "SEDENA intervention (official data)" sedena_cide_t5_atuesta "SEDENA intervention (CIDE-PPD data)" ///
	   lag1_hom "Homicide rate (t-1)" loggdppercap "GDP per capita (logged)" deudapib100 "Debt/GDP" taxgdp100 "Taxation/GDP" taxgdp100 "Taxation/GDP" ///
	   divided "Divided government" educ "Education (years)" l.count "Lagged DV") ///
	   note("Note: Entries are coefficients from OLS regressions. Standard errors clustered at the state level in parenthesis. + p<0.1; * p<0.05; ** p<0.01; *** p<0.001") ///
	   title("Table A.IV.b. The Impact of Militarization on Attacks on Journalists by Mexican State Using SEDENA and CIDE-PPD Data ") replace
	   
	   
**** Figure	A.IV.a
eststo clear
** No controls
eststo: reghdfe count opsedena_sold_of_atuestat1, cluster(statecode) a(year statecode) // official info
	eststo mod_soldiers_official
estadd local statefe  "Y" 
estadd local yearfe  "Y" 
estadd local controls  "" 

eststo: reghdfe count opsedena_sold_press_atuestat1, cluster(statecode) a(year statecode) // press info when discrepancies arise
	eststo mod_soldiers_press
estadd local statefe  "Y" 
estadd local yearfe  "Y" 
estadd local controls  "" 

** Inspired by https://medium.com/the-stata-gallery/making-regression-coefficient-plots-in-stata-7b100feac0cb
coefplot mod_soldiers_official, ///
drop(_cons) xline(0, lcolor(red) lwidth(medium)) scheme(white_jet) ///
graphregion(margin(medsmall)) ///
xsize(6.5) ysize(4.5) ///
xlab(, glpattern(solid) glcolor(gs14)) /// 
grid(glpattern(solid) glcolor(gs14)) /// 
ylab(, labsize(*1.1)) /// 
subtitle("{bf: Official data}", color(white) box fcolor(black)) ///
coeflabels(opsedena_sold_of_atuestat1=`""Number of troops deployed" "in military operations""') ///
msize(large) mcolor(%85) mlcolor(cyan) mlwidth(medium) msymbol(circle) /// applies to all markers
levels(95 90) ciopts(lcolor(magenta midblue) lwidth(medthick thick) recast(rspike rcap)) /// applies to all CIs
saving(mod_official.gph, replace)


coefplot mod_soldiers_press, ///
drop(_cons) xline(0, lcolor(red) lwidth(medium)) scheme(white_jet) ///
xtitle("{bf: Effect on journalist assassination}") /// bolded text
graphregion(margin(medsmall)) ///
xsize(6.5) ysize(4.5) ///
xlab(, glpattern(solid) glcolor(gs14)) /// 
grid(glpattern(solid) glcolor(gs14)) /// 
ylab(, labsize(*1.1)) /// 
subtitle("{bf: Official + press data}", color(white) box fcolor(black)) ///
coeflabels(opsedena_sold_press_atuestat1=`""Number of troops deployed" "in military operations""') ///
msize(large) mcolor(%85) mlcolor(cyan) mlwidth(medium) msymbol(circle) /// applies to all markers
levels(95 90) ciopts(lcolor(magenta midblue) lwidth(medthick thick) recast(rspike rcap)) /// applies to all CIs
saving(mod_press.gph, replace)

graph combine "mod_official.gph" "mod_press.gph", scheme(white_jet) graphregion(margin(tiny)) xsize(6.5) ysize(4.5) ///
ycommon /// make the y-axes of constituent graphs identical (xcommon does this for x-axes)
xcommon /// make the y-axes of constituent graphs identical (xcommon does this for x-axes)
col(1) /// array the panels in 1 column (that is, on top of one another)
imargin(medium) /// make the margins between the panels size medium
iscale(.9) /// reduce the text size slightly (can often be too large when combining graphs)
note("Note: 90% and 95% CIs shown. Official data come from SEDENA reports, supplemented in the graph below by newspaper articles.", size(vsmall) span) // add a note


**** Figure A.V.a
set more off
regress count_d i.jointopsyeardummy i.year i.statec, r
margins  i.year i.jointopsyeardummy, atmeans post
#delimit;
coefplot, vertical  keep(1994.year  //
1995.year 1996.year 1997.year 1998.year 1999.year 2000.year 2001.year 2002.year 2003.year 2004.year 2005.year 2006.year 2007.year 2008.year //
2009.year 2010.year 2011.year 2012.year 2013.year 2014.year 2015.year) xline(12)  xline(14) xline(26, lpattern(dash))  recast(line) lwidth(*1.3) lcolor(black) ciopts(recast(rline) lpattern(shortdash_dot) color(black*.7%10%))  //  
coeflabels(1994.year ="1994" //
1995.year ="1995" 1996.year ="1996" 1997.year ="1997" 1998.year ="1998" 1999.year ="1999" 2000.year ="2000" 2001.year ="2001"  2002.year ="2002" 2003.year ="2003" 2004.year ="2004" 2005.year ="2005" 2006.year ="2006" 2007.year ="2007" 2008.year ="2008"//
2009.year ="2009" 2010.year ="2010"  2011.year ="2011" 2012.year ="2012" 2013.year ="2013" 2014.year ="2014" 2015.year ="2015") 
graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) 
xlabel(, angle(vertical) labsize(small))  
xtitle(, size(medium)) 
ylabel(, labsize(small))
ytitle(Predicted Rate, size(medium))
name(time_trends, replace)
;
graph export "Figure A.V.a.png", replace width(1100) height(450)

**** Table A.VI.a
eststo clear
** Other specifications for H1
* Unit specific trends
set more off
eststo: reghdfe count jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ, cluster(statecode) a(i.year c.year##i.statec)
	estadd local unittrend  "Y"

* State x Year FE
eststo: reghdfe count jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ, cluster(statecode) a(c.year##i.statec)
	estadd local stateyearfe  "Y" 


* LDV
eststo: reghdfe count jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ l.count, cluster(statecode) a(i.year)
	estadd local yearfe  "Y"


esttab using "Table A.VI.a.rtf", cell(b(star fmt (%9.2f)) se(par)) mtitles("DID" "DID" "LDV") ///
       uns drop(_cons) compress fonttbl(\f0\fnil Garamond; ) ///
       stats(N unittrend stateyearfe yearfe, fmt(%9.0g) labels("N" "Unit-specific time trends" "State-by-Year FE" "Year FE")) ///
	   starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
	   o(jointopsyeardummy) ///
	   note("Note: Entries are coefficients from OLS regressions. Standard errors clustered at the state level in parenthesis. + p<0.1; * p<0.05; ** p<0.01; *** p<0.001") ///
	   varlabels(jointopsyeardummy "Military intervention" lag1_hom "Homicide rate (t–1)" loggdppercap "GDP per capita (logged)" deudapib100 "Debt/GDP" taxgdp100 "Taxation/GDP" taxgdp100 "Taxation/GDP"  divided "Divided government" educ "Education (years)" l.count "Lagged DV") ///
	   title("Table A.VI.a. The Impact of Militarization on the Murder of Journalists (Alternative Specifications) ") replace

**** Table A.VI.b
eststo clear
** Testing parallel trends with leads and lags (Granger-type causality test)
* W/o covariates
eststo: reghdfe count L(-3/3).jointopsyeardummy, cluster(statecode) absorb(year statecode)
	estadd local yearfe  "Y"
	estadd local statefe  "Y"

* W/ covariates
eststo: reghdfe count L(-3/3).jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ, cluster(statecode) absorb(year statecode)
	estadd local yearfe  "Y"
	estadd local statefe  "Y"

esttab using "Table A.VI.b.rtf", cell(b(star fmt (%9.2f)) se(par)) ///
       uns drop(_cons) compress fonttbl(\f0\fnil Garamond; ) ///
       stats(N statefe yearfe, fmt(%9.0g) labels("N" "State FE" "Year FE")) ///
	   starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
	   o(jointopsyeardummy lag1_hom loggdppercap deudapib100 taxgdp100 divided educ) ///
	   note("Note: Entries are coefficients from OLS regressions. Standard errors clustered at the state level in parenthesis. + p<0.1; * p<0.05; ** p<0.01; *** p<0.001") ///
	   varlabels(jointopsyeardummy "Military intervention" F3.jointopsyeardummy "Military intervention (t+3)" F2.jointopsyeardummy "Military intervention (t+2)" ///
	   F.jointopsyeardummy "Military intervention (t+1)" L3.jointopsyeardummy "Military intervention (t-3)" ///
	   L2.jointopsyeardummy "Military intervention (t-2)" L.jointopsyeardummy "Military intervention (t-1)" ///
	   lag1_hom "Homicide rate (t-1)" loggdppercap "GDP per capita (logged)" deudapib100 "Debt/GDP" taxgdp100 "Taxation/GDP" taxgdp100 "Taxation/GDP"  divided "Divided government" educ "Education (years)" l.count "Lagged DV") ///
	   title("Table A.VI.b. The Impact of Militarization (Granger causality tests)") replace


**** Table A.VIII.c
use "data_Torture_Journ.dta",clear
eststo clear
**** Table A.VI.c.
eststo: reghdfe institutional_torture_dum jointopsyeardummy, absorb(year statec i.Sex i.occupation i.cat_age i.education i.wealth_cat4 i.noread_write i.indigenous) vce(cluster clave)
		estadd local statefe  "Y" 
		estadd local yearfe  "Y" 

eststo: reghdfe brute_force_dum jointopsyeardummy, vce(cluster clave) a(i.Sex i.occupation i.cat_age i.education i.wealth_cat4 i.noread_write i.indigenous i.year i.statecode) // SE clustered at municipality
		estadd local statefe  "Y" 
		estadd local yearfe  "Y" 

eststo: reghdfe threat_dum jointopsyeardummy, vce(cluster clave) a(i.Sex i.occupation i.cat_age i.education i.wealth_cat4 i.noread_write i.indigenous i.year i.statecode) // SE clustered at municipality
		estadd local statefe  "Y" 
		estadd local yearfe  "Y"
		
esttab using "Table A-VI-c.rtf", cell(b(star fmt (%9.2f)) se(par)) ///
       uns keep(jointopsyeardummy) compress mtitles(OLS OLS Logit Logit) fonttbl(\f0\fnil Garamond; ) ///
       stats(N statefe yearfe, fmt(%9.0g) labels("N" "State FE" "Year FE"))starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
	   o(jointopsyeardummy) ///
	   note("Note: All models control for socioeconomic characteristics (sex, education, age at arrest, occupation, income, illiteracy, and whether the individual speaks an indigenous language). + p<0.1; * p<0.05; ** p<0.01; *** p<0.001") ///
	   varlabels(jointopsyeardummy "Military intervention") ///
	   title("Table A.VI.c. The Impact of Militarization on Torture") replace





















